<?php

include_once($mcrp . 'config/config.php');

class SQL
{
	public $dbhost;
	public $dbname;
	public $dbuser;
	public $dbpass;
	
	private $link;
	private $count;
	
	function __construct()
	{
		global $config;
		$this->dbhost = $config['dbhost'];
		$this->dbname = $config['dbname'];
		$this->dbuser = $config['dbuser'];
		$this->dbpass = $config['dbpass'];
		$this->count = 0;
	}
	
	function SetConfig($dbhost_, $dbname_, $dbuser_, $dbpass_)
	{
		$this->dbhost = $dbhost_;
		$this->dbname = $dbname_;
		$this->dbuser = $dbuser_;
		$this->dbpass = $dbpass_;
	}
	
	function Connect()
	{
		global $mcrp;
		$this->link = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
		if(!$this->link) return false;
		if(mysql_select_db($this->dbname, $this->link))	return $this->link;
		return false;
	}
	
	function Query($request)
	{
		if($this->link == null) $this->Connect();
		$this->count++;
		return mysql_query($request);
	}
	
	function GetCount() { return $this->count; }
}

?>